import $axios from './api'
import axios from 'axios';
import { showFailToast } from 'vant';
import config from './config';
import { user, publishType, commentType } from '../model/index'
import router from '../router/index';
let expiredRequestArr: any[] = [];
const login = (data: user) => {
    return $axios({
        url: '/login',
        data: data,
        method: 'POST'
    })
}
const register = (data: user) => {
    return $axios({
        url: '/register',
        data: data,
        method: 'POST'
    })
}
const getToken = () => {
    return $axios({
        url: '/getToken',
        method: 'get'
    })
}
const publish = (data: publishType) => {
    return $axios({
        data: data,
        url: '/publish',
        method: 'POST'
    })
}
const getCardList = () => {
    return $axios({
        url: '/getCardList',
        method: 'get'
    })
}
const getChatInfo = (id: string) => {
    return $axios({
        url: '/getChatInfo',
        data: { chatId: id },
        method: 'POST'
    })
}
const setAttent = (data: { follower_Id: any; userId: string; isattent: boolean }) => {
    return $axios({
        url: '/addAttention',
        data: data,
        method: 'POST'
    })
}

const delPublish = (id: string) => {
    return $axios({
        url: '/delPublish',
        data: { card_id: id },
        method: 'POST'
    })
}

const getCardCommentByCardId = (id: string) => {
    return $axios({
        url: '/getCardCommentByCardId',
        data: { card_id: id },
        method: 'post'
    })
}

const pubComment = (data: commentType) => {
    return $axios({
        url: '/pubComment',
        data: data,
        method: 'POST'
    })
}

const delCommentById = (id: string) => {
    return $axios({
        url: '/delComment',
        data: { comment_id: id },
        method: 'POST'
    })
}

const searchByKeyWord = (keyword: string) => {
    return $axios({
        url: '/searchByKeyWord',
        data: { keyword },
        method: 'post'
    })
}

const approval = (data: any) => {
    return $axios({
        url: '/approval',
        data,
        method: 'post'
    })
}

const getApprovalList=(id:string,type:string)=>{
    return $axios({
        url:'/getapprovalList',
        data:{id,type},
        method:'post'
    })
}

const setApprovalStatus=(data: { id: string | string[]; status: any; })=>{
    return $axios({
        url:'/setApprovalStatus',
        data,
        method:'post'
    })
}

const getApprovalDetail=(id:string)=>{
    return $axios({
        url:'/getApprovalDetail',
        data:{id},
        method:'post'
    })
}

const cancelApproval=(id:string)=>{
    return $axios({
        url:'/cancelApproval',
        data:{id},
        method:'post'
    })
}

const queryagreementList=(id:string)=>{
    return $axios({
        url:'/getagreementList',
        data:{id},
        method:'post'
    })
}

const queryAgreementDetail=(id:string)=>{
    return $axios({
        url:'/getagreementDetail',
        data:{id},
        method:'post'
    })
}

const updateSign=(img:string,type:string,id:string)=>{
    return $axios({
        url:'/updateSign',
        data:{image:img,type,id},
        method:'post'
    })
}

const getShareList=()=>{
    return $axios({
        url: '/getShareList',
        method: 'get'
    })
}


const handleCollection=(data:any)=>{
    return $axios({
        url: '/editCollection',
        data,
        method:'post'
    })
}

const getCollectionList=(data:any)=>{
    return $axios({
        url: '/getCollectList',
        data,
        method:'post'
    })
}

const getMycollectionListByType=(data:any)=>{
    return $axios({
        url: '/getMycollectionList',
        data,
        method:'post'
    })
}


const realNameAuthentication=(data:any)=>{
    return $axios({
        url: '/RealNameAuthentication',
        data,
        method:'post'
    })
}
const setUserInfo=(data:any)=>{
    return $axios({
        url: '/setUserInfo',
        data,
        method:'post'
    })
}

const addhistory=(data:any)=>{
    return $axios({
        url: '/addhistory',
        data,
        method:'post'
    })
}

const getHistory=(data:any)=>{
    return $axios({
        url: '/getHistory',
        data,
        method:'post'
    })
}

const getuserInfo=(data:any)=>{
    return $axios({
        url: '/getuserInfo',
        data,
        method:'post'
    })
}


export {
    login,
    register,
    getToken,
    publish,
    getCardList,
    getChatInfo,
    setAttent,
    delPublish,
    getCardCommentByCardId,
    pubComment,
    delCommentById,
    searchByKeyWord,
    approval,
    getApprovalList,
    setApprovalStatus,
    getApprovalDetail,
    cancelApproval,
    queryAgreementDetail,
    queryagreementList,
    updateSign,
    getShareList,
    handleCollection,
    getCollectionList,
    realNameAuthentication,
    setUserInfo,
    getMycollectionListByType,
    addhistory,
    getHistory,
    getuserInfo
}